package compiler;

/**
 * @author tjc
 * @date 2020-3-9
 */
//type value line byte
public class Token {

    TokenKind type;
    OPType opType;
    String value;
    int line;
    int column;

    public Token(TokenKind type, OPType opType, String value, int line, int column) {
        this.type = type;
        this.opType = opType;
        this.value = value;
        this.line = line;
        this.column = column;
    }

    public Token(TokenKind type, String value, int line, int column) {
        this.type = type;
        this.value = value;
        this.line = line;
        this.column = column;
    }


    @Override
    public String toString() {
        return "Token{" +
                "type=" + type +
                ", value='" + value + '\'' +
                ", opType='" + opType +
                ", line=" + line +
                ", column=" + column +
                '}';
    }

    public String print() {
        StringBuilder str = new StringBuilder();
        str.append("[ ");
        str.append(type);
        str.append(" line:" +line );
        str.append(" value:" + value);
        str.append("]");
        return str.toString();
    }
}